/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/3/29
 * \* Time: 18:06
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class Demo18 {
    private static Object locker = new Object();
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            synchronized (locker){
                //1.进行wait
                System.out.println("wait之前");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t1.start();

        Thread.sleep(3000);

        Thread t2 = new Thread(()->{
            //2.进行notify
            synchronized (locker){
                System.out.println("notify之前");
                locker.notify();
                System.out.println("notify之后");
            }
        });
        t2.start();
    }
}
